#include <bits/stdc++.h>
#define int long long
using namespace std;
int t;
int n,m,L,V;
struct node
{
    int d,v,a;
}car[4002];
pair<int,int>fast[4002];
int len;
int judge[4002];
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>t;
    while(t--)
    {
        int sum=0;
        int farthest_j=0;
        cin>>n>>m>>L>>V;
        bool check=false;
        for(int i=1; i<=n; i++)
        {
            cin>>car[i].d>>car[i].v>>car[i].a;
            if(car[i].a!=0)
                check=true;
        }
        for(int i=1; i<=m; i++)
        {
            cin>>judge[i];
            farthest_j=max(farthest_j,judge[i]);
        }
        if(!check)
        {
            int speical_judge=0;
            for(int i=1; i<=n; i++)
                if(car[i].v>V && car[i].d<=farthest_j)
                    speical_judge++;
            cout<<speical_judge<<" "<<m-1<<endl;
            continue;
        }
        for(int i=1; i<=n; i++)
        {
            if((car[i].v>V && car[i].a>=0 && car[i].d<=farthest_j) || (car[i].v==V && car[i].a>0 && car[i].d<farthest_j))
            {
                sum++;
                ++len;
                fast[len].first=car[i].d;
                fast[len].second=farthest_j;
                continue;
            }
            int fast_dis=ceil((V*V*1.0-car[i].v*car[i].v*1.0)/(2.0*car[i].a))+car[i].d;
            if(car[i].v>V && car[i].a<=0)
            {
                for(int j=1; j<=m; j++)
                {
                    if(judge[j]>=car[i].d && judge[j]<fast_dis)
                    {
                        sum++;
                        len++;
                        fast[len].first=car[i].d;
                        fast[len].second=fast_dis-1;
                        break;
                    }
                }
            }
            if(car[i].v<V && car[i].a>0)
            {
                if(fast_dis<=farthest_j)
                {
                    sum++;
                    len++;
                    fast[len].first=fast_dis+1;
                    fast[len].second=farthest_j;
                }
            }
        }
        cout<<sum<<" ";
        int use=0;
        for(int i=m; i>=1; i--)
        {
            bool useful=false;
            for(int j=1; j<=len; j++)
            {
                if(judge[i]>=fast[j].first && judge[i]<=fast[j].second)
                {
                    if(!useful)
                    {
                        use++;
                        useful=true;
                    }
                    fast[j].first=L+1;
                    fast[j].second=-1;
                }
            }
        }
        cout<<m-use<<endl;
    }
    return 0;
}
